#ifndef TILE_H
#define TILE_H

#include <ncurses.h>
#include <vector>
#include <sstream>
#include <iostream>

#include "colors.h"
#include "movable.h"
#include "player.h"
#include "monster.h"

using namespace std;

class Player;
class Monster;

class Space
{
public:
  Space();
  Space(bool, bool);
  char display();
  char displayBase();
  int getFore();
  int getBack();
  int getType();
  bool passable();
  bool isClosed();
  bool isOpen();
  void closeDoor();
  void openDoor();
  void restoreBase();
  void addPlayer(Player* p);
  void addMonster(Monster* m);
  Player* getPlayer();
  Monster* getMonster();
  void removePlayer();
  void removeMonster(Monster* m);
  void load(int);
private:
  char d;
  bool isWall;
//  bool isPlayer;
  bool isOpenDoor;
  bool isClosedDoor;
  int fore, back;
  int baseFore, baseBack, baseD;
  int type;
  MovableList* inSpace;
//  int movePos(int, int);
};

class Map
{
  friend class Loader;
  friend class Saver;
public:
  Map();
  Map(int);
  Space* getSpace(int, int);
  void start();
  int getFore(int, int);
  int getBack(int, int);
  int movePos(int, int);
  int moveCreature(int, int, int);
  int getPosX();
  int getPosY();
  int getHeight();
  int getWidth();
private:
  Space*** map;
  vector<Creature*> creatures;
  int height;
  int width;
  int posX;
  int posY;
};

#endif
